﻿<%@ WebHandler Language="C#" Class="Advertisement_AddEdit" %>

using System;
using System.Web;
using System.Data;
using System.Data.Common;

public class Advertisement_AddEdit : IHttpHandler
{
    public void ProcessRequest(HttpContext context)
    {
        context.Response.ContentType = "text/plain";
        string Status = "0";

        /* 管理员身份验证 */
        if (!Admins.IsLogin(true))
            Utils.ShowEnd(context, "-2");
        /* 外部数据接收 */
        int Item_Id = Convert.ToInt32(context.Request.Params["Item_Id"].ToString());
        int Orders = Convert.ToInt32(context.Request.Params["Orders"].ToString());
        string Item_Css = context.Request.Params["Item_Css"].ToString();
        int Item_Lang = Convert.ToInt32(context.Request.Params["Item_Lang"].ToString());
        int Item_Column = Convert.ToInt32(context.Request.Params["Item_Column"].ToString());
        string Item_Url = context.Request.Params["Item_Url"].ToString();
        string Item_Title = context.Request.Params["Item_Title"].ToString();
        DateTime Item_Time = Convert.ToDateTime(context.Request.Params["Item_Time"].ToString());
        DateTime Maturity_Time = Convert.ToDateTime(context.Request.Params["Maturity_Time"].ToString());
        
        /* 进行转码 */
        Item_Css = Utils.HtmlEncode(Item_Css);
        Item_Title = Utils.HtmlEncode(Item_Title);
        

        /* 数据完整性验证 */
        if (Orders < 0 || Orders > 255)
            Utils.ShowEnd(context, "-1");
        if (Item_Title.Length < 1)
            Utils.ShowEnd(context, "-1");
        
        /* 数据库处理 */
        Advertisement Ad = new Advertisement();
        Status = Ad.Advertisement_AddEdit(Item_Id, Orders, Item_Lang, Item_Url, Item_Css, Item_Title, Item_Column, Item_Time, Maturity_Time).ToString();

        /* 返回最终执行效果 */
        Utils.ShowEnd(context, Status);


    }

    public bool IsReusable
    {
        get
        {
            return false;
        }
    }



}